-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UI and controller to interact with Rackscale simulator APIs. #711
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good!
|
||
def show | ||
@title = "Welcome to RackScale Design" | ||
@redfish_client = RedfishHelper::RedfishClient.new('10.160.66.119', '8443') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can initialise the client as part of the class so we dont have to create a client per method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, missing getting the host+port from env variables.
@title = "Welcome to RackScale Design" | ||
@redfish_client = RedfishHelper::RedfishClient.new('10.160.66.119', '8443') | ||
sys_list = get_all_systems() | ||
p "SYSTEM LIST: #{sys_list}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rails.logger instead of p?
afb3a36
to
94ae042
Compare
f19f2ec
to
8e9db87
Compare
8e9db87
to
fb944d1
Compare
# consider some better cache/expiration strategy. | ||
if @@domain.nil? | ||
dns_proposal = Proposal.where(barclamp: "dns", name: "default").first | ||
@@domain = dns_proposal[:attributes][:dns][:domain] unless dns_proposal.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/ClassVars: Replace class var @@Domain with a class instance var. (https://github.com/bbatsov/ruby-style-guide#no-class-vars)
# consider some better cache/expiration strategy. | ||
if @@domain.nil? | ||
dns_proposal = Proposal.where(barclamp: "dns", name: "default").first | ||
@@domain = dns_proposal[:attributes][:dns][:domain] unless dns_proposal.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/ClassVars: Replace class var @@Domain with a class instance var. (https://github.com/bbatsov/ruby-style-guide#no-class-vars)
|
||
module Crowbar | ||
class Settings | ||
@@domain = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/ClassVars: Replace class var @@Domain with a class instance var. (https://github.com/bbatsov/ruby-style-guide#no-class-vars)
|
||
module Crowbar | ||
class Settings | ||
@@domain = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/ClassVars: Replace class var @@Domain with a class instance var. (https://github.com/bbatsov/ruby-style-guide#no-class-vars)
end | ||
JSON.load(network_proposal[3]) | ||
else | ||
JSON.load(json_path.read) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Security/JSONLoad: Prefer JSON.parse over JSON.load. (http://ruby-doc.org/stdlib-2.3.0/libdoc/json/rdoc/JSON.html#method-i-load)
end | ||
JSON.load(network_proposal[3]) | ||
else | ||
JSON.load(json_path.read) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Security/JSONLoad: Prefer JSON.parse over JSON.load. (http://ruby-doc.org/stdlib-2.3.0/libdoc/json/rdoc/JSON.html#method-i-load)
network_proposal = proposals["proposals"]["records"].detect do |p| | ||
p[1] == "network" && p[2] == "default" | ||
end | ||
JSON.load(network_proposal[3]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Security/JSONLoad: Prefer JSON.parse over JSON.load. (http://ruby-doc.org/stdlib-2.3.0/libdoc/json/rdoc/JSON.html#method-i-load)
network_proposal = proposals["proposals"]["records"].detect do |p| | ||
p[1] == "network" && p[2] == "default" | ||
end | ||
JSON.load(network_proposal[3]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Security/JSONLoad: Prefer JSON.parse over JSON.load. (http://ruby-doc.org/stdlib-2.3.0/libdoc/json/rdoc/JSON.html#method-i-load)
return "Windows Server 2012" if target_platform == "windows-6.2" | ||
return "Hyper-V Server 2012 R2" if target_platform == "hyperv-6.3" | ||
return "Hyper-V Server 2012" if target_platform == "hyperv-6.2" | ||
return target_platform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/RedundantReturn: Redundant return detected. (https://github.com/bbatsov/ruby-style-guide#no-explicit-return)
return "Windows Server 2012" if target_platform == "windows-6.2" | ||
return "Hyper-V Server 2012 R2" if target_platform == "hyperv-6.3" | ||
return "Hyper-V Server 2012" if target_platform == "hyperv-6.2" | ||
return target_platform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/RedundantReturn: Redundant return detected. (https://github.com/bbatsov/ruby-style-guide#no-explicit-return)
) | ||
end | ||
|
||
it "checks for node repositories" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/BlockLength: Block has too many lines. [32/25]
) | ||
end | ||
|
||
it "checks for node repositories" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/BlockLength: Block has too many lines. [32/25]
require "spec_helper" | ||
|
||
describe Api::UpgradeController, type: :request do | ||
context "with a successful upgrade API request" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/BlockLength: Block has too many lines. [158/25]
require "spec_helper" | ||
|
||
describe Api::UpgradeController, type: :request do | ||
context "with a successful upgrade API request" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/BlockLength: Block has too many lines. [158/25]
@@ -0,0 +1,186 @@ | |||
require "spec_helper" | |||
|
|||
describe Api::UpgradeController, type: :request do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/BlockLength: Block has too many lines. [160/25]
@@ -0,0 +1,186 @@ | |||
require "spec_helper" | |||
|
|||
describe Api::UpgradeController, type: :request do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/BlockLength: Block has too many lines. [160/25]
@@ -0,0 +1,36 @@ | |||
require "spec_helper" | |||
|
|||
describe Api::ErrorsController, type: :request do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/BlockLength: Block has too many lines. [26/25]
@@ -0,0 +1,36 @@ | |||
require "spec_helper" | |||
|
|||
describe Api::ErrorsController, type: :request do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/BlockLength: Block has too many lines. [26/25]
require "spec_helper" | ||
|
||
describe Api::CrowbarController, type: :request do | ||
context "with a successful crowbar API request" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/BlockLength: Block has too many lines. [66/25]
require "spec_helper" | ||
|
||
describe Api::CrowbarController, type: :request do | ||
context "with a successful crowbar API request" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/BlockLength: Block has too many lines. [66/25]
@@ -0,0 +1,79 @@ | |||
require "spec_helper" | |||
|
|||
describe Api::CrowbarController, type: :request do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/BlockLength: Block has too many lines. [68/25]
options[:show] << :bios unless options[:bios].empty? | ||
|
||
options = { raid: {}, bios: {}, show: [] } | ||
unless proposals[0]["attributes"].nil? or proposals[0]["attributes"]["crowbar"].nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/AndOr: Use || instead of or. (https://github.com/bbatsov/ruby-style-guide#no-and-or-or)
options = { raid: {}, bios: {}, show: [] } | ||
|
||
proposals = Proposal.where(barclamp: "crowbar") | ||
raise "Can't find any crowbar proposal" if proposals.nil? or proposals[0].nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/AndOr: Use || instead of or. (https://github.com/bbatsov/ruby-style-guide#no-and-or-or)
if @@domain.nil? | ||
dns_proposal = Proposal.where(barclamp: "dns", name: "default").first | ||
@@domain = dns_proposal[:attributes][:dns][:domain] unless dns_proposal.nil? | ||
end | ||
|
||
if @@domain.nil? | ||
return `dnsdomainname`.strip | ||
return %x{dnsdomainname}.strip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/CommandLiteral: Use backticks around command string. (https://github.com/bbatsov/ruby-style-guide#percent-x)
@@domain = nil | ||
|
||
class << self | ||
def domain | ||
# FIXME: We are using a global here to avoid lookups. We need to | ||
# consider some better cache/expiration strategy. | ||
# NOTE: We are using a global here to avoid lookups. We need to consider some better cache/expiration strategy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [119/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength)
@@ -16,51 +16,39 @@ | |||
|
|||
module Crowbar | |||
class Settings | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/EmptyLinesAroundClassBody: Extra empty line detected at class body beginning.
end | ||
# Install route from each barclamp | ||
Rails.root.join("config", "routes.d").children.each do |routes| | ||
eval(routes.read, binding) if routes.extname == ".routes" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint/Eval: The use of eval is a serious security risk.
end | ||
end | ||
# Install route from each barclamp | ||
Rails.root.join("config", "routes.d").children.each do |routes| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/MultilineIfModifier: Favor a normal if-statement over a modifier clause in a multiline statement. (https://github.com/bbatsov/ruby-style-guide#no-multiline-if-modifiers)
else | ||
next unless ip_addr.ipv4? | ||
addresses.push address if ip_addr.ipv4? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/IfInsideElse: Convert if nested inside else to elsif.
# end | ||
#unless ipv6_configured || ipv6_addrs.empty? | ||
# return false | ||
#end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/LeadingCommentSpace: Missing space after #. (https://github.com/bbatsov/ruby-style-guide#hash-space)
# unless ipv6_configured || ipv6_addrs.empty? | ||
# return false | ||
# end | ||
#unless ipv6_configured || ipv6_addrs.empty? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/LeadingCommentSpace: Missing space after #. (https://github.com/bbatsov/ruby-style-guide#hash-space)
@@ -1579,7 +1633,7 @@ def process_raid_boot | |||
return true | |||
end | |||
|
|||
false | |||
return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/RedundantReturn: Redundant return detected. (https://github.com/bbatsov/ruby-style-guide#no-explicit-return)
@@ -1562,7 +1616,7 @@ def process_raid_member(device, attributes) | |||
end | |||
end | |||
|
|||
false | |||
return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/RedundantReturn: Redundant return detected. (https://github.com/bbatsov/ruby-style-guide#no-explicit-return)
@@ -1544,7 +1598,7 @@ def process_raid_device(device, attributes) | |||
end | |||
end | |||
|
|||
false | |||
return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/RedundantReturn: Redundant return detected. (https://github.com/bbatsov/ruby-style-guide#no-explicit-return)
Rails.logger.warn "Alias #{value}.#{domain} FQDN not saved because it exceeded the 63 character length limit or it's length (#{value.length}) will cause the total DNS max of 255 to be exeeded." | ||
raise "#{I18n.t("too_long_dns_alias", scope: "model.node")}: #{value}.#{domain}" | ||
raise "#{I18n.t('too_long_dns_alias', scope: 'model.node')}: #{value}.#{domain}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiteralsInInterpolation: Prefer double-quoted strings inside interpolations. (https://github.com/SUSE/style-guides/blob/master/Ruby.md#stylestringliteralsininterpolation)
9a37d09
to
99e4866
Compare
end | ||
|
||
# commit current proposal (with the crowbar-upgrade role still assigned to nodes), | ||
# so the recipe is executed when nodes have 'ready' state | ||
proposal_commit("default", false, false) | ||
self.proposal_commit("default", false, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/RedundantSelf: Redundant self detected. (https://github.com/bbatsov/ruby-style-guide#no-self-unless-required)
node["crowbar_wall"]["crowbar_upgrade_step"] = "revert_to_ready" | ||
node.save | ||
node.set_state("ready") | ||
if node.state == "crowbar_upgrade" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/Next: Use next to skip iteration. (https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals)
if ssh_status[0] != 200 | ||
save_error_state("Failed to reboot the machine. Could not ssh.") | ||
# Join the cluster: start pacemaker and run selected recipes | ||
script = "/usr/sbin/crowbar-post-upgrade.sh" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint/UnreachableCode: Unreachable code detected.
- Lists available systems from Rackscale Simulator - Allows selection of specific systems for allocation - Creates a node object and allocates the same as a crowbar node - Also refined the controller to obtain system-specific info - UI contains only a list of check-boxes and one Allocate button
…ocalhost and default port On node creation: - set the proper node+domain for the node object - set the node name to the short name - set the fqdn and domain name to the proper ones - set the uptime to avoid failure on node details UI - set the roles to just names so they are linked to the barclamps - set the product name, serial number so they are shown properly in the UI - set the disk key for removable so disks are shown properly on the UI - count all the memory and aggregate it to be shown on the UI - count the processors with an 0 index so they can be shown in the UI - allocate the node - set the node to ready status All the node creation changes also fix the node not being shown properly when going to the details as well as crowbar crashing when moving the node to a different group
- Store 2 more items in the NodeObject to identify and track the rackscale instances - Rewrite the rest-client queries to protect and log http exceptions - Create several Power management shortcuts for the RedFish client - Create a handler for redfish commands - On power management actions, check for rackscale and execute the actions via rest calls
99e4866
to
c27d8f9
Compare
@port = @rsd_server_port | ||
Rails.logger.warn "RackScale Server: #{@host}, Port: #{@port}" | ||
#@redfish_client = RedfishHelper::RedfishClient.new(host, port) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/TrailingWhitespace: Trailing whitespace detected. (https://github.com/bbatsov/ruby-style-guide#no-trailing-whitespace)
@host = @rsd_rest_server | ||
@port = @rsd_server_port | ||
Rails.logger.warn "RackScale Server: #{@host}, Port: #{@port}" | ||
#@redfish_client = RedfishHelper::RedfishClient.new(host, port) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/LeadingCommentSpace: Missing space after #. (https://github.com/bbatsov/ruby-style-guide#hash-space)
- Added text boxes to edit PSME server IP and port.
c27d8f9
to
7310846
Compare
Provides a basic UI interface for RackScale systems:
NOTE: The UI need not be final and only done for easier test and a basic demo.
Here are a few sample screen-shot.
This PR depends on #693